package com.reggie.common;

import lombok.extern.slf4j.Slf4j;

/**
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 */
@Slf4j
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static void setCurrentUserId(Long id) {
        log.info("当前线程ID：{}", Thread.currentThread().getId());
        threadLocal.set(id);
    }

    public static Long getCurrentUserId() {
        log.info("当前线程ID：{}", Thread.currentThread().getId());
        return threadLocal.get();
    }
}
